import { createApp } from 'vue'
import App from './App.vue'
import './styles/index.scss'
import { setupRouter } from './router'
import { setupStore } from './store'
import * as directives from './directives'
import { type Directive } from 'vue'
import { Bread, BreadItem } from './components/bread'
import { IconifyIcon } from './components/icons'

/** 创建vue示例对象 */
const app = createApp(App)

/** 安装vue-router */
setupRouter(app)
/** 安装pinia */
setupStore(app)

/** 注册全局指令 */
Object.keys(directives).forEach((key) => {
  app.directive(key, (directives as Record<string, Directive>)[key])
})

/** 注册全局组件 */
app.component('IconifyIcon', IconifyIcon)
app.component('Bread', Bread)
app.component('BreadItem', BreadItem)

/** 挂载的目标根节点：单页面应用的根节点设置为id为app的元素 */
app.mount('#app')
